#include "../include/threadPool.h"

/* Usage*/
int get_salt(char *salt){
    char randomSalt[18] = {0};
    char getsalt[1024] = {0};
    const char randomNum[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./";
    srand (time(NULL));
    for(int i=0; i<16 ;i++){
        int idx = rand()%64;
        randomSalt[i] = randomNum[idx];
    }
    randomSalt[16] = '$';
    randomSalt[17] = '\0';
    snprintf(getsalt, sizeof(getsalt),"$6$%s",randomSalt);
    strcpy(salt, getsalt);
    return 0;

}
//todo....................
/* int get_salt(char *salt) */
/* { */
/*     char randomSalt[31] = {0}; */
/*     strcpy(randomSalt,"$y$j9T$"); */
/*     randomSalt[29] = '$'; */
    
/*     char randomNum[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./"; */
/*     srand (time(NULL)); */
/*     for(int i = 7;i < 29;i++) */
/*     { */ 
/*         int idx = rand()%64; */
/*         randomSalt[i] = randomNum[idx]; */
/*     } */
/*     /1* char *result =(char *)malloc(31); *1/ */
/*     /1* strcpy(result,randomSalt); *1/ */
/*     /1* return result; *1/ */
/*     strncpy(salt,randomSalt,31); */
/*     return 0; */
/* } */
/* int main() */
/* { */ 
/*     char *salt = get_salt(); */
/*     printf("sali = %s\n",salt); */
/*     return 0; */
/* } */
